/**
 * \class CLoader
 * \brief This is a loader for dynamic library.
 *
 * \version 0.1
 *
 * \author Woo-Hyun Kim (woorung@nhncorp.com, woorung@gmail.com)
 * \author http://blog.naver.com/wisereign .
 *
 * \date 2008/11/04
 */
//----------------------------------------------------------------------
#include "CLoader.h"
//----------------------------------------------------------------------
CLoader::CLoader(char *library)
{
	handle = dlopen(library, RTLD_LAZY);
	if(!handle) {
		cerr << "error : dlopen() = " << dlerror() << endl;
		exit(-1);
	}
}
//----------------------------------------------------------------------
CLoader::~CLoader()
{
	dlclose(handle);
}
//----------------------------------------------------------------------
void *CLoader::get_func(char *func_name)
{
	void *func_p = dlsym(handle, func_name);
	if(dlerror()!=NULL) {
		cerr << "error : dlsym() = " << func_name << endl;
		exit(-1);
	}

	return func_p;
}
//----------------------------------------------------------------------
